/*
 * XXX
 */

package edu.uhcl.csci4838.group3.view;

import edu.uhcl.csci4838.group3.R;
import edu.uhcl.csci4838.group3.database.BackpackEduDatabaseHelper;
import edu.uhcl.csci4838.group3.database.BackpackEduDatabaseHelper.CursorCourse;
import edu.uhcl.csci4838.group3.database.BackpackEduDatabaseHelper.CursorFaculty;
import edu.uhcl.csci4838.group3.database.info.Course;
import edu.uhcl.csci4838.group3.database.info.Faculty;
import android.app.Activity;
import android.content.ContentValues;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.os.Bundle;
import android.widget.TextView;

/**
 * XXX
 * 
 * @author Chris Waguespack
 *
 */
public class FacultyActivity extends Activity {
	
	/**
	 * The database helper object.
	 */
	private static BackpackEduDatabaseHelper dbHelper;
	
	/**
	 * The faculty cursor used to populate this view.
	 */
	private CursorFaculty facultyCursor;
	
	private static TextView tvFacultyName;
	
	/**
	 * XXX
	 * 
	 * @param savedInstanceState
	 */
	/* 
	 * (non-Javadoc)
	 * 
	 * @see android.app.ActivityGroup#onCreate(android.os.Bundle)
	 */
	@Override
	public void onCreate(final Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
		this.setContentView(R.layout.activity_view_faculty);
		
		tvFacultyName = (TextView) findViewById(R.id.textView_facultyName);

		// Calling intent
		Intent callingIntent = getIntent();
		long facultyId = callingIntent.getLongExtra(getString(R.string.intent_extra_facultyId),
				-1);
		
		// Cursor
		dbHelper = new BackpackEduDatabaseHelper(this);
		ContentValues criteria = new ContentValues();
		criteria.put(Faculty.ID,
				facultyId);
		this.facultyCursor = dbHelper.getFaculty(criteria,
				null,
				true);
		startManagingCursor(this.facultyCursor);
		
		// Populate the fields
		tvFacultyName.setText(this.facultyCursor.getColFirstName() + " " + this.facultyCursor.getColLastName());
	}
}
